Ultrasonic sensor is a device that uses ultrasonic waves (waves with a frequency higher than 20 kHz) for measurement and detection
Optical sensor: It is greatly affected by lighting conditions
Optical sensors are sensitive to the color, transparency, and surface texture of objects.